<?php
/**
 * Created by PhpStorm.
 * User: 何健喔喔喔
 * Date: 2016/12/28
 * Time: 14:47
 */

   
class oauth2{
    
    function getCode(){
        if (isset($_GET['code'])){
            echo $_GET['code'];
           /* $code=$_GET['code'];
            $url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxf2c0b4cfd0018d0e&secret=55926fccdebee063eff40a6604f3b088&code={$code}&grant_type=authorization_code";
            echo $code;
            $result=http_curl($url);
            var_dump($result);*/
        }else{
            echo "NO CODE";
    }

    }
    
    
    private function http_url($url){
        $ch=curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLINFO_HEADER_OUT,true);
        $opt=curl_exec($ch);
        curl_close($ch);
        return $opt;
    }
}
echo $this->getCode();